package com.ruoyi.web.controller.device;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Dc3DeviceChangeCapEvent;
import com.ruoyi.system.service.IDc3DeviceChangeCapEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2025-01-06
 */
@RestController
@RequestMapping("/device/cap/event")
public class Dc3DeviceChangeCapEventController extends BaseController
{
    @Autowired
    private IDc3DeviceChangeCapEventService dc3DeviceChangeCapEventService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:event:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dc3DeviceChangeCapEvent dc3DeviceChangeCapEvent)
    {
        startPage();
        List<Dc3DeviceChangeCapEvent> list = dc3DeviceChangeCapEventService.selectDc3DeviceChangeCapEventList(dc3DeviceChangeCapEvent);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:event:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Dc3DeviceChangeCapEvent dc3DeviceChangeCapEvent)
    {
        List<Dc3DeviceChangeCapEvent> list = dc3DeviceChangeCapEventService.selectDc3DeviceChangeCapEventList(dc3DeviceChangeCapEvent);
        ExcelUtil<Dc3DeviceChangeCapEvent> util = new ExcelUtil<Dc3DeviceChangeCapEvent>(Dc3DeviceChangeCapEvent.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:event:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dc3DeviceChangeCapEventService.selectDc3DeviceChangeCapEventById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:event:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dc3DeviceChangeCapEvent dc3DeviceChangeCapEvent)
    {
        return toAjax(dc3DeviceChangeCapEventService.insertDc3DeviceChangeCapEvent(dc3DeviceChangeCapEvent));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:event:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dc3DeviceChangeCapEvent dc3DeviceChangeCapEvent)
    {
        return toAjax(dc3DeviceChangeCapEventService.updateDc3DeviceChangeCapEvent(dc3DeviceChangeCapEvent));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:event:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dc3DeviceChangeCapEventService.deleteDc3DeviceChangeCapEventByIds(ids));
    }
}